unit IndyUtils;

interface

uses
  SysUtils, Classes,
  IdBaseComponent, IdComponent,  IdTCPConnection, IdTCPClient, IdHTTP;


function DownLoadFileViaWeb(SrcURL,  LocalFileName: String): Boolean;  

implementation

uses
  CodeSiteLogging;


function DownLoadFileViaWeb(SrcURL,  LocalFileName: String): Boolean;
var
   Source : TMemoryStream;
   Http: TIdHTTP;
begin
  Result := False;
   Source := TMemoryStream.Create;
   try
      Http:= TIdHTTp.Create(nil);
      try
        HTTP.Get( srcUrl , Source );
        source.Position := 0;
        source.SaveToFile(LocalFileName);
        if FileExists(LocalFileName) then Result := True;
      Except on E:Exception do
        begin
          CodeSite.SendError( format('%s Download Fail:%s', [  SrcURL, e.Message ]  ));
        end;
      end;
   finally
      Source.Free;
      http.free;
   end;
end;


end.
